package com.shop.admin.config;

import com.shop.admin.interceptors.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration //定义此类为配置类，及相当于之前的xml文件
public class InterceptorConfig implements WebMvcConfigurer{

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //排除接口
				String[] excludePathPatterns = {"/api/AdminLogin","/api/school/admin/login","/api/webSocket/sentMessage"};
        //已经提供了拦截器注册类 放进来相当于定义了一个bean
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/api/**")
                .excludePathPatterns(excludePathPatterns);
    }
}
